<template>
  <div class="content">
    <!-- 标题 -->
    <div class="contentTop">
      <h2 class="title">{{title}}</h2>
      <div class="more" @click="morsShop"><span>查看更多</span></div>
    </div>
    <!-- 轮播 -->
    <div class="contentSwiper">
      <swiper
        ref="mySwiper"
        :options="swiperOptions"
        class="content"
        autoplay="true"
      >
        <swiper-slide v-for="item in hotShopData" :key="item.id">
          <div class="presentation" @click="stDetails(item)">
            <div class="img">
              <img :src="item.url" alt="" />
            </div>
            <div class="info">
              <p class="info-con">{{item.desc}}</p>
              <div class="price">
                <p><span>￥</span>{{item.price}}</p>
              </div>
            </div>
          </div>
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
    <!-- 大图 -->
    <div class="bigImg">
      <img :src="imgUrl" alt="" />
    </div>
  </div>
</template>

<script>
import api from "../../api"
export default {
  name: "HomeHotShop",
  data() {
    return {
      hotShopData:[],
      title:"",
      imgUrl:"",
      swiperOptions: {
        // autoplay: {
        //   disableOnInteraction: false, // 用户操作swiper之后，是否禁止autoplay
        //   delay: 3000, // 自动切换的时间间隔（单位ms）
        // },
        slidesPerView: 1.5,
        spaceBetween: 10,
      },
    };
  },
  methods:{
    morsShop(){
      this.$router.push('/sitetesting')
    },
    stDetails(id){
      this.$router.push(
        {
          name:'StDetails',
          params:{
            id:id
          }
        }
      )
    }
  },
  mounted(){
    api.getHotShop().then(res=>{
      // console.log(res.data);
      this.title = res.data.title
      this.imgUrl = res.data.imgUrl
      this.hotShopData = res.data.list
    })
  }
};
</script>

<style lang="less" scoped>
.contentTop {
  width: 100%;
  height: 26px;
  line-height: 26px;
  padding: 12px 0;
  //   margin-bottom: 15px;
  //   box-sizing: border-box;
  .title {
    float: left;
    margin-left: 10px;
    width: 73px;
    height: 26px;
    line-height: 26px;
    color: rgba(51, 51, 51, 1);
    font-size: 18px;
    text-align: center;
    font-family: Arial;
  }
  .more {
    float: right;
    margin-right: 10px;
    width: 49px;
    height: 23px;
    line-height: 17px;
    color: rgba(153, 153, 153, 1);
    font-size: 12px;
    text-align: center;
    font-family: Arial;
  }
}
.contentSwiper {
  height: 227px;
}
// 轮播图
.presentation {
  width: 100%;
  height: 227px;
  .img {
    width: 230px;
    height: 130px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .info {
    width: 215px;
    height: 40px;
    padding: 9px 11px;
    line-height: 20px;
    color: rgba(51, 51, 51, 1);
    text-align: left;
    font-family: Arial;
    .info-con {
      font-size: 14px;
      margin-bottom: 11px;
    }
    .price {
      height: 100px;
      p {
        width: 72px;
        height: 23px;
        line-height: 20px;
        color: rgba(130, 0, 133, 1);
        font-size: 14px;
        // text-align: center;
        font-family: Arial;
      }
    }
  }
}
// 大图
.bigImg {
  width: 100%;
  height: 94px;
  padding: 5px 0;
  background-color: #eee;
  img {
    width: 100%;
    height: 100%;
  }
}
</style>